package fcrpt

class ProductionRateController {
    def dynamicQueryService
    def productionRate(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList=[]
        def productionRate=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def productionRateSumQty=[]
        def orderStatusAnalysisStartedList=[]
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'productionRate'
            productionRate = dynamicQueryService.queryForList(params)
            if (productionRate.size() > 0) {
                tableHeadList = productionRate[0].keySet()
            }
            params.SYS_QUERY_NAME = 'productionRateCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

            params.SYS_QUERY_NAME = 'productionRateSumQty'
            productionRateSumQty = dynamicQueryService.queryForList(params)


        }
        params.SYS_QUERY_NAME = 'orderStatusAnalysisStartedList'
        orderStatusAnalysisStartedList = dynamicQueryService.queryForList(params)
        print(orderStatusAnalysisStartedList)
        [startno:params.startno?:'',
         endno:params.endno?:'',
         pageSize:pageSize,
         totalCount: totalCount,
         pageSizeList: pageSizeList,
         tableHeadList:tableHeadList,
         productionRate:productionRate,
         productionRateSumQty:productionRateSumQty,
         startTime:params.startTime?:'',
         endTime:params.endTime?:'',
         partName:params.partName?:'',
         tuhao:params.tuhao?:'',
         parentId:params.parentId?:'',
         yield:params.yield?:'',
         startedState:params.startedState?:'',
         scrapRatio:params.scrapRatio?:'',
         orderStatusAnalysisStartedList:orderStatusAnalysisStartedList
        ]
    }
}
